<?php

namespace App\Controller;

use Grpc\CalculateRequest;
use Grpc\CalculateResponse;

class CalculateController extends AbstractController
{
    public function add(CalculateRequest $request): CalculateResponse
    {
        return (new CalculateResponse())->setRes($request->getA() + $request->getB());
    }

    public function sub(CalculateRequest $request): CalculateResponse
    {
        return (new CalculateResponse())->setRes($request->getA() - $request->getB());
    }

    public function mul(CalculateRequest $request): CalculateResponse
    {
        return (new CalculateResponse())->setRes($request->getA() * $request->getB());
    }

    public function div(CalculateRequest $request): CalculateResponse
    {
        return (new CalculateResponse())->setRes($request->getA() / $request->getB());
    }
}